<template>
	<view class='content'>
		<view class="message-detail">
			<view class="message-top">
				<view class="title">
					
					<view class="" v-if="detail.type ==1">
						系统消息
					</view>
					<view class="" v-else-if="detail.type ==2">
						积分变动
					</view>
					<view class="" v-else>
						通知
					</view>
				</view>
				<view class="time">
					{{ detail.time}}
				</view>
			</view>
			
			<view class="desc">
				<rich-text :nodes="detail.description"></rich-text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: '',
				detail: {}
			}
		},
		onLoad(option) {
			this.id = option.id
			console.log(this.id)
			this.read()
			this.getdetail()
		},
		methods: {
			changeTime(time){
				const dateObj = new Date(time * 1000);
				 
				// 获取年月日时分秒
				let year = dateObj.getFullYear();
				let month = (dateObj.getMonth() + 1).toString().padStart(2, '0');
				let day = dateObj.getDate().toString().padStart(2, '0');
				let hours = dateObj.getHours().toString().padStart(2, '0');
				let minutes = dateObj.getMinutes().toString().padStart(2, '0');
				let seconds = dateObj.getSeconds().toString().padStart(2, '0');
				
				return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
			},
			getdetail(){
				var _this = this
				this.fq_post('wxsite/User/messageFind', {
					id: _this.id
				}, (res) => {
					console.log(res)
					if(res.code == 1){
						_this.detail = res.data
					}
				})
				// uni.request({
				// 	url: 'http://www.yndzfl.cn/wxsite/User/messageFind',
				// 	method: 'POST',
				// 	header:{
				// 		"Content-Type" : "application/x-www-form-urlencoded"
				// 	},
				// 	data: {
				// 		openid: uni.getStorageSync('OPENID'),
				// 		id: _this.id
				// 	},
				// 	success(res) {
				// 		console.log(res)
				// 		if(res.data.code == 1){
				// 			_this.detail = res.data.data
				// 		}
						
				// 	}
				// })
			},
			read(){
				var _this = this
				this.fq_post('wxsite/User/messageRead', {
					id: _this.id
				}, (res) => {
					console.log(res)
					if(res.code == 1){
						
					}
				})
				
			}
		}
	}
</script>

<style scoped>
.content{
	min-height: 100vh;
	background-color: #f6f6f6;
}
.message-detail{
	margin: 20rpx;
	background-color: #fff;
	min-height: calc(100vh - 40rpx);
}
.message-top{
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 5px;
	line-height: 30px;
}
.title{
	font-size: 16px;
	color: #333;
	font-weight: bold;
}
.time{
	color: #9e9e9e;
	font-size: 14px;
}
.desc{
	line-height: 30px;
	padding: 5px;
	font-weight: 500;
}
</style>
